﻿Chenxin.UI.LinkageManage = Chenxin.extend(Chenxin.UI.PageCommon, {
    autoInitForm: false,
    actionUrl: '/service/logic/ShowListLinkage.ashx',
    createSearch: function() {
        return new Chenxin.UI.LinkageManageSearch({
            scope: this
        });
    },
    createGrid: function() {
        return new Chenxin.UI.JsonGrid({
            actionUrl: this.actionUrl + '?op=getlist',
            pageSize: 100,
            hasPage: true,
            cellBorder: true,
            height: 400,
            autoLoad: false,
            renderTo: 'LinkageManage_table',
            hasCheckBox: true,
            id: 'searchtable',
            modelId: 'RecordId',
            title: '联动业绩列表',
            scope: this,
            columns: {
                UserCode: {
                    width: 100,
                    head: '工号',
                    sortable: true
                },
                UserName: {
                    width: 150,
                    head: '业务员',
                    sortable: true
                },
                DepartName: {
                    width: 150,
                    head: '门店',
                    sortable: true
                },
                ItemName: {
                    width: 150,
                    head: '项目名称',
                    sortable: true
                },
                AchievementDate: {
                    width: 80,
                    head: '业绩归属',
                    sortable: true
                },
                CustomerName: {
                    width: 150,
                    head: '客户姓名',
                    sortable: true
                },
                Ridgepole: {
                    width: 80,
                    head: '幢号',
                    sortable: true
                },
                Floor: {
                    width: 80,
                    head: '楼号',
                    sortable: true
                },
                Room: {
                    width: 80,
                    head: '房号',
                    sortable: true
                },
                Area: {
                    width: 150,
                    head: '面积',
                    sortable: true
                },
                BargainTime: {
                    width: 90,
                    head: '大定日期',
                    sortable: true
                },
                BargainUnit: {
                    width: 150,
                    head: '成交单价',
                    sortable: true
                },
                BargainTotal: {
                    width: 150,
                    head: '成交总价',
                    sortable: true
                },
                SignName: {
                    width: 150,
                    head: '签约姓名',
                    sortable: true
                },
                SignTime: {
                    width: 90,
                    head: '签约日期',
                    sortable: true
                },
                SignTotal: {
                    width: 150,
                    head: '签约总价',
                    sortable: true
                },
                SupplyCommisionScale: {
                    width: 150,
                    head: '代理佣金比例',
                    sortable: true
                },
                Achievement: {
                    width: 150,
                    head: '业绩',
                    sortable: true
                },
                EmpCommisionScale: {
                    width: 150,
                    head: '业务员佣金比例',
                    sortable: true
                },
                EmpCommision: {
                    width: 150,
                    head: '业务员佣金',
                    sortable: true
                },
                DZCommisionScale: {
                    width: 150,
                    head: '店长佣金比例',
                    sortable: true
                },
                DZCommision: {
                    width: 150,
                    head: '店长佣金',
                    sortable: true
                },
                ZJCommisionScale: {
                    width: 150,
                    head: '区经理佣金比例',
                    sortable: true
                },
                ZJCommision: {
                    width: 150,
                    head: '区经理佣金',
                    sortable: true
                }
            }
        });
    },
    initEvent: function() {
        var _this = this;
        $('#inputdata').click(function() {
            _this.showupload();
        });
        $('#deldata').click(function() {
            _this.delList(); 
        });
    },
    showupload: function() {
        var _this = this;
        if (!this.uploadForm) {
            this.uploadForm = new Chenxin.UI.UploadLinkageForm({
                scrop: this,
                title: '导入数据',
                op: 'uploaddata',
                saveSucc: function() {
                    _this.grid.reload();
                }
            });
        }
        if (this.uploadForm.show(this.uploadForm.op, { currentId: _this.currentId })) {
            this.uploadForm.reset();
            $('#upload').hide();
        }
        var curdate = new Date();
        $('#txtDateTime').val(curdate.getFullYear() + '-' + (curdate.getMonth() + 1) + '-' + curdate.getDate());
    },
    initComponent: function() {
        Chenxin.UI.LinkageManage.superclass.initComponent.call(this);
    }
});


/**
*查询面板
*/
Chenxin.UI.LinkageManageSearch = Chenxin.extend(Chenxin.UI.SearchCommon, {
    id: 'LinkageManage_search',
    initEvent: function() {
        var _this = this;

        //查询按钮
        $('#btnSreach').click(function() {
            _this.scope.reloadGrid("",0);
        });

        $('#txtKeyword').defText({
            deftxt: '输入项目名称'
        });
        var curdate = new Date();
        $('#txtTime').val(curdate.getFullYear() + '-' + (curdate.getMonth() + 1));
        
        /********事件：实收归属日期******/
        $("#txtTime").focus(function() {
            WdatePicker({
                dateFmt: 'yyyy-MM',
                oncleared: function() {
                    $(this).blur();
                },
                onpicked: function() {
                    $(this).blur();
                }
            });
        });
    },
    createComboList: function() {
        var combl = new Chenxin.UI.StructComboList({tbxWidth: 60});
        var structs = combl.comboList;
        return structs;
    },
    initComponent: function() {
        Chenxin.UI.LinkageManageSearch.superclass.initComponent.call(this);
    }
});

$(document).ready(function() {
    this.LinkageManage = new Chenxin.UI.LinkageManage();
});